import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;

public class Postman {
    public static String send(InetAddress address, int port, Object parcel) {
        try {
            Socket socket = new Socket(address, port);
            Serialization.writeObject(socket, parcel);
            String result = (String) Serialization.readObject(socket);
            socket.close();
            return result;
        } catch (IOException e) {
            return "Can't send query to server! Error: " + e.getMessage();
        } catch (ClassNotFoundException e) {
            return "Can't read query result from server! Error: " + e.getMessage();
        }
    }
}
